const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()
  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
/**静态数据 */
const index = require('../data/data_index.js')
const index_next = require('../data/data_index_next.js')
const discovery = require('../data/data_discovery.js')
const discovery_next = require('../data/data_discovery_next.js')
const getData2 = () => index.index
const getNext = () => index_next.next
const getDiscovery = () => discovery.discovery
const discoveryNext = () => discovery_next.discovery
/**封装获取数据的接口 */
const getData = (url) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: url,
      data: {},
      header: {},
      success: function(res){
        console.log(res)
        resolve(res)
      },
      fail: function(res) {
        console.log('failed')
        reject(res)
      }
    })
  })
}
module.exports = {
  formatNumber,
  formatTime,
  getData,
  getData2,
  getNext,
  getDiscovery,
  discoveryNext,
}
